//
// Created by Felix on 24-4-26.
//

#ifndef GAZE_AUTHSERVICE_HPP
#define GAZE_AUTHSERVICE_HPP

#include "oatpp/web/protocol/http/Http.hpp"
#include "oatpp/core/macro/component.hpp"

#include "db/UserDb.hpp"
#include "db/LoginLogDb.hpp"
#include "dto/SignInDto.hpp"
#include "dto/AuthResponseDto.hpp"
#include "dto/UserResponseDto.hpp"

class AuthService {
private:
    typedef oatpp::web::protocol::http::Status Status;
    OATPP_COMPONENT(std::shared_ptr<UserDb>, iUserDatabase);
    OATPP_COMPONENT(std::shared_ptr<LoginLogDb>, iLoginLogDatabase);
public:
    oatpp::Object<AuthResponseDto> signIn(const oatpp::Object<SignInDto> &dto); //
    void signOut(oatpp::String &token); //
    oatpp::Object<UserResponseDto> getUserByToken(const oatpp::String &token); //
private:
    static oatpp::Object<UserResponseDto> userResponseDtoFromModel(const oatpp::Object<UserModel> &model); //
};

#endif //GAZE_AUTHSERVICE_HPP
